/*
 * FramePanel.java
 *
 * Copyright (C) 2013 UPOU.
 * IS214 - Programming Languages
 * All Rights Reserved.
 *
 * @author Mary Joy Pascual and Simon Zagado
 */

package com.upittc.flopol.gui;

import java.awt.Dimension;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.UIManager;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;

import com.upittc.flopol.gui.helper.TextLineNumberHelper;

public class FramePanel extends JPanel {

	private static final long serialVersionUID = 1L;

	public JTextArea editor;
	public JTextArea console;
	public DefaultTableModel tokenTable;
	public DefaultTableModel symbolTable;
	
	public FramePanel(){
		initConsolePanel();
	}

	private void initConsolePanel() {
		setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		setLayout(null);
		setSize(1000, 600);

		// SYMPOL TABLE
		JPanel panel_2 = new JPanel();
		panel_2.setBorder(new TitledBorder(null, "Symbol Table",
				TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_2.setBounds(680, 11, 297, 333);
		// TODO
		add(panel_2);
		
		symbolTable = new DefaultTableModel(){
			private static final long serialVersionUID = 1L;
			public boolean isCellEditable(int row, int column) {
		       return false;
		    }
		};; 
		
		JTable table1 = new JTable(symbolTable);
		table1.setFillsViewportHeight(true);
		symbolTable.addColumn("Var Type"); 
		symbolTable.addColumn("Var Name"); 
		symbolTable.addColumn("Value"); 
		
		JScrollPane scrollPane1 = new JScrollPane(table1);
		Dimension dim2 = new Dimension(275,295);
		scrollPane1.setPreferredSize(dim2);
		panel_2.add(scrollPane1);

		// TOKENS
		JPanel panel_3 = new JPanel();
		panel_3.setBorder(new TitledBorder(null, "Token Table",
				TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_3.setBounds(680, 355, 297, 221);
		add(panel_3);
		
		tokenTable = new DefaultTableModel(){
			private static final long serialVersionUID = 1L;
		    public boolean isCellEditable(int row, int column) {
		       return false;
		    }
		};

		JTable table = new JTable(tokenTable);
		table.setFillsViewportHeight(true);
		tokenTable.addColumn("Token"); 
		tokenTable.addColumn("Lexeme"); 
	
		JScrollPane scrollPane = new JScrollPane(table);
		Dimension dim = new Dimension(275,183);
		scrollPane.setPreferredSize(dim);
		panel_3.add(scrollPane);

		// EDITOR
		editor = new JTextArea();
		editor.setTabSize(2);
		JPanel panel = new JPanel();
		panel.setBorder(new TitledBorder(UIManager
				.getBorder("TitledBorder.border"), "Editor",
				TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel.setBounds(21, 11, 649, 333);
		add(panel);
		
		panel.setLayout(null);

		JScrollPane sp1 = new JScrollPane(editor);
		TextLineNumberHelper tln = new TextLineNumberHelper(editor);
		sp1.setRowHeaderView(tln);
		sp1.setBounds(10, 22, 629, 300);

		panel.add(sp1);

		// CONSOLE
		JPanel panel_1 = new JPanel();
		panel_1.setBorder(new TitledBorder(null, "Console",
				TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_1.setBounds(21, 355, 649, 221);

		add(panel_1);
		panel_1.setLayout(null);

		console = new JTextArea();
		console.setEditable(false);
		JScrollPane sp = new JScrollPane(console);
		sp.setBounds(10, 21, 629, 185);
		panel_1.add(sp);

	}

	public JTextArea getEditor() {
		return editor;
	}

	public void setEditor(JTextArea editor) {
		this.editor = editor;
	}

	public JTextArea getConsole() {
		return console;
	}

	public void setConsole(JTextArea console) {
		this.console = console;
	}

	public DefaultTableModel getTokenTable() {
		return tokenTable;
	}

	public void setTokenTable(DefaultTableModel tokenTable) {
		this.tokenTable = tokenTable;
	}

	public DefaultTableModel getSymbolTable() {
		return symbolTable;
	}

	public void setSymbolTable(DefaultTableModel symbolTable) {
		this.symbolTable = symbolTable;
	}
	
	

}
